package com.imti.roomdemo;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;
import java.util.List;

@Dao
public interface StuDAO
{

    //OnConflictStrategy.ABORT(默认)  如果遇到插入的重复数据，则忽略重复，继续插入
    //OnConflictStrategy.IGNORE 如果遇到插入的重复数据，则终止插入操作
    //OnConflictStrategy.REPLACE 如果遇到插入的重复数据，则替换掉表中原有数据
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertStu(StuEntity student);

    @Delete
    int delete(StuEntity student);

    @Update
    int updateStu(StuEntity student);

    @Query("select * from stu_info")
    List<StuEntity> queryAll();

    @Query("select * from stu_info")
    StuEntity[] queryStu();
}
